package peer.rudp;

public class TunnelInputStream {
	TunnelUDP tun;
	ConnectionUDP conn;
	TunnelInputStream(ConnectionUDP conn,TunnelUDP tun){
		this.conn=conn;
		this.tun=tun;
	}
	public int read(byte[] b, int off, int len) throws ConnectException{
		int length=conn.receive(tun,b,off,len);
		return length;
	}
	
	public byte[] readCommand() throws ConnectException{
		byte[] b=new byte[1024];
		int length=0;
		length = read(b, 0, b.length);
		byte[] b2=new byte[length];
		System.arraycopy(b, 0, b2, 0, length);
		return b2;
	}
}
